﻿
@{
    ViewBag.Title = "查询门诊详细资料";
    Layout = "~/Views/Shared/_Index.cshtml";
    var reportUrl = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportUrl");
    var reportSystemCode = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportSystemCode");
    var curOpr = Newtouch.Common.Operator.OperatorProvider.GetCurrent();
}
<script src="~/Content/js/bootstrap-multiselect.js"></script>
<link href="~/Content/js/bootstrap-multiselect.css" rel="stylesheet" />
<style>
    .showbotton {
        display: none;
        position: fixed;
        bottom: 5px;
        right: 0;
        z-index: 9999;
        background-color: #ccc;
        width: 50px;
        height: 44px;
        filter: alpha(Opacity=90);
        -moz-opacity: 0.9;
        opacity: 0.9;
        cursor: pointer;
        border-radius: 100px 0 0 100px;
    }

    #TabGrid {
        width: 100%;
        position: fixed;
        bottom: 10px;
        right: 0;
        z-index: 8888;
        background-color: #253443;
        filter: alpha(Opacity=92);
        -moz-opacity: 0.92;
        opacity: 0.92;
        box-shadow: 0px 2px 10px #909090;
    }

        #TabGrid > * {
            filter: alpha(Opacity=92);
            -moz-opacity: 0.92;
            opacity: 0.92;
        }
   </style>
<form name="form1">
    <div class="panel panel-default">
        <div class="panel-heading navb-bg">
            筛选条件
        </div>
        <table class="form">
            <tr>
                <th class="formTitle">日期：</th>
                <td class="formValue" style="width:10%">
                    <input id="kssj" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:90px"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                </td>
                <td class="formValue" style="width:10%;float:left;">
                    <input id="jssj" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:90px;float:left;"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                </td>
                <td class="formValue">
                    <input type="button" id="btn_search" class="btn btn-primary btn-md" style="margin-left: 10px; width: 40px;" value="查询" />
                    <input type="button" id="btn_print" class="btn btn-primary btn-md" style="margin-left: 10px; width: 40px;" value="打印" />
                </td>
            </tr>
        </table>
    </div>
    <div class="gridPanel">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
    <div id="TabGrid">
        <ul class="nav nav-tabs navb-bg" role="tablist" id="myTab">
            <li role="presentation" class="active">
                <a href="#dv_djmx" id="linkSearch" role="tab" data-toggle="tab">处方明细</a>
            </li>
            <li style="float:right">
                <span class="hiding glyphicon glyphicon-chevron-right btn-lg"></span>
            </li>
        </ul>
        <div id="dv_djmx" style="">
            <table id="gridDJMXInfo"></table>
        </div>
    </div>
    <div class="showbotton">
        <span class="glyphicon glyphicon-chevron-left btn-lg"></span>
    </div>
</form>
<script>
    $(function () {
        //浏览器窗口调整大小时重新加载jqGrid的宽
        $(window).resize(function () {
            initLayout("MyTabGrid");
        });
        $(".hiding,.rows,#dv_search,.toolbar,.panel-default").click(function () {
            TabGridHide();
        });
        $(".showbotton").click(function () {
            $(".showbotton").animate({ width: 'hide' }, "fast", function () {
                $("#TabGrid").animate({ left: '0px' }, "slow");
            });
        });
        TabGridHide();
        //查询列表
        gridList();
    });
    //隐藏搜索框并显示箭头
    function TabGridHide() {
        var tabGridwith = $("#TabGrid").width() + 200;
        if ($(".showbotton").is(":hidden")) {
            $("#TabGrid").animate({ left: tabGridwith }, "slow", function () {
                $(".showbotton").animate({ width: 'show' }, "fast");
            });
        }
    }
    //门诊挂号结算查询
    function gridList() {
        var $gridJsList = $("#gridList");
        $gridJsList.dataGrid({
            postData: { kssj: $("#kssj").val(), jssj: $("#jssj").val() },
            height: $(window).height() - 160,
            width: "100px",
            url: "/DoctorManage/OutpatientQuery/GetOutpatientDetailGridJson",
            colModel: [
                { label: '就诊时间', name: 'jzsj', align: 'center', width: 120, formatter: function (val) { return $.getTime({ date: val }); } },
                { label: '门诊号码', name: 'mzh', width: 100, align: 'center' },
                { label: '患者姓名', name: 'xm', align: 'center', width: 110 },
                { label: '性别', name: 'xb', align: 'center', width: 50 },
                { label: '病人性质', name: 'brxzmc', align: 'center', width: 70 },
                { label: '就诊科室', name: 'jzks', width: 80, align: 'center' },
                { label: '处方数', name: 'cfs', align: 'center', width: 50 },
                { label: '处方金额', name: 'cfje', align: 'center', width: 50 },
                { label: '检查数', name: 'jcs', align: 'center', width: 50 },
                { label: '检查金额', name: 'jcje', align: 'center', width: 50 },
                { label: '附加项目', name: 'fjxm', align: 'left', width: 50 },
            ],
            pager: "#gridPager",
            sortname: " jzsj asc",
            rownumbers: true,  //是否显示序号
            viewrecords: true,
            ondblClickRow: function (rowid, iRow, iCol, e) {
                btn_selectrow(rowid);
            }
        });

        $("#btn_search").click(function () {
            $('#gridList').jqGrid("clearGridData");//先清空明细
            $gridJsList.jqGrid('setGridParam', {
                postData: { kssj: $("#kssj").val(), jssj: $("#jssj").val() },
                url: "/DoctorManage/OutpatientQuery/GetOutpatientDetailGridJson",
            }).trigger('reloadGrid');
        });
    }
        function btn_selectrow(rowId) {
            $('#gridDJMXInfo').jqGrid("clearGridData");//每次单击，先清空明细 再重新加载所有选中行明细
            $.najax({
                type: "Get",
                url: "/DoctorManage/OutpatientQuery/GetOutpatientDetailMX",
                data: { mzh: $("#gridList").jqGrid('getRowData', rowId).mzh },
                dataType: "json",
                success: function (ajaxresp) {
                    if (ajaxresp !== null) {
                        $('#gridDJMXInfo').newtouchLocalDataGrid(null, ajaxresp);
                    }
                    $(".showbotton").click().trigger("click");
                }
            });
            //单据明细
            
    }
        $('#gridDJMXInfo').newtouchLocalDataGrid({
            height: $(window).height() - 200,
            unwritten: false,
            sortable: false,
            colModel: [
                { label: '类别', name: 'lb', width: 40, align: 'center' },
                { label: '医生', name: 'ys', width: 60, align: 'center' },
                { label: '开单日期', name: 'kdrq', align: 'center', width: 120, formatter: function (val) { return $.getTime({ date: val }); } },
                { label: '项目名称', name: 'xmmc', width: 300, align: 'center' },
                { label: '总量', name: 'zl', width: 80, align: 'center' },
                { label: '药品用法', name: 'ypyf', width: 90, align: 'center' },
                { label: '金额', name: 'je', width: 100, align: 'left' },
            ]
        });

     $("#btn_print").click(function () {
         var uri = '@Html.Raw(reportUrl)' + "?tempCode=1248" + "&systemCode=" + '@reportSystemCode' + "&hospitalCode=" + '@ViewBag.OrganizeId' + "&kssj=" + $('#kssj').val() + "&jssj=" + $('#jssj').val() + "&jzys=" + '@curOpr.rygh';
        if (uri) {
            window.open(uri);
        }
    })



</script>